home *** CD-ROM | disk | FTP | other *** search
/ APC & TCP 4 / APC & TCP 4.iso / games / publicdomain / a / attacks / sources / thinker.def < prev    next >
Text File  |  1994-05-14  |  4KB  |  72 lines

  1. DEFINITION MODULE thinker;
  2.  
  3. (*$R-V-*)        (* Range checking OFF, overflow checking OFF *)
  4.  
  5. (*   The Thinker!  This is the meat and potatoes of Attacks.  Here is     *)
  6. (* where the computer does all of its thinking.  This is also where the   *)
  7. (* most improvements can be made to the program.  EvalMove is the routine *)
  8. (* that assigns a value to a given board.  It works recursively.  Check   *)
  9. (* it out.  It's easily the most complex and sophisticated procedure I've *)
  10. (* ever written (that's saying a lot for a CS grad from UT).  But I think *)
  11. (* it's still understandable.                                             *)
  12.  
  13.  
  14. FROM header
  15.   IMPORT   movetype, boardtype, playertype;
  16.  
  17.  
  18. (************************************************************************)
  19. PROCEDURE OtherPlayer (player : playertype) : playertype;
  20.      (*   Simply returns the other player     *)
  21.  
  22.  
  23. (************************************************************************)
  24. PROCEDURE LegalMove (move : movetype) : BOOLEAN;
  25.  
  26. (*   This simply checks to see if the given move is a valid move, con- *)
  27. (* sidering the current state of the game.  It is NOT assumed that     *)
  28. (* the initial component of the move is valid.  It does NOT assume     *)
  29. (* both of the move components are valid locations.  But it does as-   *)
  30. (* sume that the board has been properly initialized so that the outer *)
  31. (* edges are blocks.  It operates using the global variable, state.    *)
  32.  
  33.  
  34. (********************************************************)
  35. PROCEDURE GoodMovePossible (board : boardtype; player : playertype)
  36.                             : BOOLEAN;
  37. (*   This procedure returns TRUE only if on the given board, player has   *)
  38. (* has a legal move available. It returns FALSE otherwise.                *)
  39.  
  40.  
  41. (***********************************************************************)
  42. PROCEDURE DoMove (move : movetype) : BOOLEAN;
  43.  
  44. (*      This does the necessary changes to facilitate a move in the    *)
  45. (* game.  It involves, finding out if the piece grows or jumps, alter- *)
  46. (* ing the board to reflect this, update the history, and change the   *)
  47. (* graphics.  Lastly, don't forget to change the player's turn!  Oh    *)
  48. (* yeah, I did in fact forget.  Change the colors of all the opponents *)
  49. (* who are adjacent to the new blob!                                   *)
  50. (*      This routine returns TRUE if there's a move available.  It     *)
  51. (* will return FALSE when the game is over.                            *)
  52.  
  53. (**************************************************************************)
  54. PROCEDURE DoComputerMove() : BOOLEAN;
  55.  
  56. (*   This is the computer equivalent of the procedure, DoMove.  It exe-   *)
  57. (* cutes a computer's move, assuming that the computer already has a le-  *)
  58. (* gitate move possible.  It utilizes the global variable, state.  Also   *)
  59. (* note that this assumes that the current turn is the computer's turn.   *)
  60. (* It's up to the caller to make sure that it is indeed time to play the  *)
  61. (* computer.                                                              *)
  62. (*                                                                        *)
  63. (*   INPUT                                                                *)
  64. (*            n/a                                                         *)
  65. (*                                                                        *)
  66. (*   OUTPUT                                                               *)
  67. (*            The state and the screen will be changed to reflect the     *)
  68. (*            move execute by the computer.                               *)
  69.  
  70.  
  71. END thinker.
  72.